home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Topik / Topik - Disk 39 - Educational (19xx)(Topik Public Domain)(PD)[WB].zip / Topik - Disk 39 - Educational (19xx)(Topik Public Domain)(PD)[WB].adf / Planets / sidereal_time.c < prev   
C/C++ Source or Header  |  1991-03-09  |  1KB  |  47 lines

  1.  
  2. #include <math.h>
  3. double range(); 
  4. extern double rad;
  5.  
  6. double 
  7. sidereal_time(jd)
  8. double jd;
  9. {
  10.    double st, t, x, ut, e;
  11.  
  12.    /* find time a UTC 0 hours */
  13.    x = .5 + floor(jd -.5);
  14.  
  15. /* they a few fractions of a second off, I don't know which one is right */
  16. #ifdef YOU_BELIEVE_THE_NAVY
  17.  
  18.    /* compute mean sidreal time according to NAVY Almanac */
  19.    t = (x - 2451545.0) / 36525;
  20.    st =  .2790572733+ 100.002139 * t + .0000010776 * t * t;
  21.    st = 24 * (st - floor(st));
  22.    
  23.    /* add in UTC with fudge factor */
  24.    ut = (jd -x) * 24 * 1.002737909;
  25.    st += ut; 
  26.  
  27.    /* compute correction for equation of equinoxes */
  28.    e = range(125.04452 - 1934.13626 * t + .002071 * t * t);
  29.    e = -.00029 * sin(e * rad) / rad; 
  30.    st += e;
  31.    if (st > 24) st -= 24;
  32. #else
  33.  
  34.    /* compute GAST according to Meeus Book */
  35.    t = (x - 2415020.0) / 36525;
  36.    st =  .276919398 + 100.0021359 * t + .000001075 * t * t;
  37.    st = 24 * (st - floor(st));
  38.    
  39.    /* add in UTC with fudge factor */
  40.    t = (jd -x) * 24 * 1.002737908;
  41.    st += t; 
  42.    if (st > 24) st -= 24;
  43. #endif
  44.  
  45.    return st;
  46. }
  47.